package util;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.example.Department;
import org.example.Teacher;

import java.util.List;

public class DepartmentControllerHelper {
    //查
    public static List<Condition> getConditions(JSONObject req_jsonObj){
        JSONArray conditionList_jsonArray = req_jsonObj.getJSONArray("conditionList");
        List<Condition> conditionList = null;
        if (conditionList_jsonArray != null){
            conditionList = conditionList_jsonArray.toJavaList(Condition.class);
        }
        return conditionList;
    }
    //查
    public static Pagination getPagination(JSONObject req_jsonObj){
        JSONObject pagination_jsonObj = req_jsonObj.getJSONObject("pagination");
        Pagination pagination = null;
        if (pagination_jsonObj !=null){
            pagination = pagination_jsonObj.toJavaObject(Pagination.class);
        }
        return pagination;
    }
    //增
    public static Department getAdd(JSONObject req_jsonObj){
        JSONObject department_jsonArray = req_jsonObj.getJSONObject("add");
        Department department = null;
        if (department_jsonArray != null){
            department = department_jsonArray.toJavaObject(Department.class);
        }
        return department;
    }
    //删
    public static Department getDelete(JSONObject req_jsonObj){
        JSONObject department_jsonArray = req_jsonObj.getJSONObject("delete");
        Department department = null;
        if (department_jsonArray != null){
            department = department_jsonArray.toJavaObject(Department.class);
        }
        return department;
    }

    //改
    public static Department getUpdate(JSONObject req_jsonObj){
        JSONObject department_jsonArray = req_jsonObj.getJSONObject("update");
        Department department = null;
        if (department_jsonArray != null){
            department = department_jsonArray.toJavaObject(Department.class);
        }
        return department;
    }
}